package com.heima.feign.fallback;

import com.heima.feign.api.article.ArticleFeignClient;
import com.heima.model.aritlce.dto.ArticleDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.search.dto.PageSearchArticleDto;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.Map;

@Slf4j
public class ArticleFeignClientFallback implements ArticleFeignClient {


    @Override
    public ResponseResult saveArticle(ArticleDto dto) {
        log.error("调用文章服务发布文章出现错误,参数:{}",dto);
        return ResponseResult.error(AppHttpCodeEnum.SERVER_ERROR);
    }

    @Override
    public ResponseResult<Void> updateEnableStatus(Long articleId, Integer enable) {
        Map<String,Object> dataMap = new HashMap<>();
        dataMap.put("articleId",articleId);
        dataMap.put("enable",enable);
        log.error("调用文章服务修改文章上下架状态出现错误,参数:{}", dataMap);
        return ResponseResult.error(AppHttpCodeEnum.SERVER_ERROR);
    }

    @Override
    public PageSearchArticleDto pageData(Integer page, Integer size) {
        log.error("调用文章服务批量导入数据出现错误,参数:{}", page, size);

        return PageSearchArticleDto.builder()
                .total(0L)
                .totalPages(0L)
                .articleVos(null)
                .build();
    }
}
